﻿using B.S.Domain.Process.AssignattributesOneModel;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.AssignattributesOneApplications
{
    public class AddAssignattributesOneCommandHorter:IRequestHandler<AddAssignattributesOneCommand,APIRequst<int>>
    {
        IBaseRepository<AssignattributesOne> processmaintenanceReq;

        public AddAssignattributesOneCommandHorter(IBaseRepository<AssignattributesOne> processmaintenanceReq)
        {
            this.processmaintenanceReq = processmaintenanceReq;
        }

        public async Task<APIRequst<int>> Handle(AddAssignattributesOneCommand request, CancellationToken cancellationToken)
        {
            var tracebackInfo = new AssignattributesOne
            {
                AssignattributesOnevalue = request.AssignattributesOnevalue,
            AssignattributesOneEncode = request.AssignattributesOneEncode,
            AssignattributesOneNamd = request.AssignattributesOneNamd,
            AssignattributesOneRemark = request.AssignattributesOneRemark,
            Id = request.Id

            };
            // 保存到数据库
            var result = await processmaintenanceReq.Add(tracebackInfo);
            return new APIRequst<int>()
            {
                
                Data = result,
                Msg = "添加成功"
            };
        }
    }
}
